home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 July / 07_02.iso / software / mdmx / files / DreamweaverMXInstaller.exe / Disk1 / data1.cab / Configuration_En / Commands / Create Component.js < prev    next >
Encoding:
JavaScript  |  2002-05-01  |  68.3 KB  |  2,558 lines

  1. // Copyright 2002 Macromedia, Inc. All rights reserved.
  2.  
  3. // *************** GLOBALS VARS *****************
  4.  
  5.  
  6. var HELP_DOC = MM.HELP_cmdCreateComponent;
  7.  
  8. var SECTION_LIST = "";
  9. var LABEL_ACCESSES = new Array ("private", "package", "public", "remote");
  10. var DEFAULT_ACCESS = "public";
  11. var LABEL_TYPES =  new Array(
  12.   "any","array","binary","boolean","date","GUID","numeric",
  13.   "query","string","struct","UUID","variableName");
  14.   
  15. var LABEL_PARENT_CFCS = new Array();
  16. var LABEL_CFC_ROOTS = new Array();
  17.   
  18. var COMPONENT_INFO = "";
  19. var FILE_DIR = "";
  20.  
  21. var TEMPLATE_URL = dw.getConfigurationPath() + "/CFComponentTemplate.cfc"
  22. var errorCount = 0;
  23.  
  24. var FORWARD_SLASH = "/";
  25. var BACK_SLASH = "\\"
  26.  
  27.  
  28. // TODO:
  29. //   Implement validation
  30. //   Remove localizable strings
  31.  
  32.  
  33. // ******************* API **********************
  34.  
  35. //--------------------------------------------------------------------
  36. // FUNCTION:
  37. //   commandButtons
  38. //
  39. // DESCRIPTION:
  40. //   The list of buttons to display on the right of the dialog,
  41. //   along with the functions to call when they are pressed.
  42. //
  43. // ARGUMENTS:
  44. //   none
  45. //
  46. // RETURNS:
  47. //   javascript array
  48. //--------------------------------------------------------------------
  49.  
  50. function commandButtons()
  51. {
  52.     return new Array(MM.BTN_OK,     "okClicked();",
  53.                    MM.BTN_Cancel, "cancelClicked()",
  54.                    MM.BTN_Help,   "displayHelp();");
  55. }
  56.  
  57.  
  58. //--------------------------------------------------------------------
  59. // FUNCTION:
  60. //   canAcceptCommand
  61. //
  62. // DESCRIPTION:
  63. //   Called to determine if the command can be displayed.
  64. //
  65. // ARGUMENTS:
  66. //   none
  67. //
  68. // RETURNS:
  69. //   boolean - true if the dialog can be launched
  70. //--------------------------------------------------------------------
  71.  
  72. function canAcceptCommand()
  73. {
  74.   return ((dw.getDocumentDOM() && dw.getDocumentDOM().getParseMode() == 'html') &&
  75.  (((dw.getFocus() == 'document') 
  76.     && (dreamweaver.getDocumentDOM("document").body)) ||
  77.     (dw.getFocus(true) == 'html' || dw.getFocus() == 'textView')) );
  78. }
  79.  
  80.  
  81. //--------------------------------------------------------------------
  82. // FUNCTION:
  83. //   okClicked
  84. //
  85. // DESCRIPTION:
  86. //   Called when the OK button is pressed.  Saves the Component.
  87. //
  88. // ARGUMENTS:
  89. //   none
  90. //
  91. // RETURNS:
  92. //   nothing
  93. //--------------------------------------------------------------------
  94.  
  95. function okClicked()
  96. {
  97.   T.finish();
  98.   
  99.   var errMsg = COMPONENT_INFO.validate();
  100.   
  101.   if (!errMsg)
  102.   {
  103.     errMsg = saveToFile();
  104.   }
  105.   
  106.   if (errMsg)
  107.   {
  108.     var fullMsg = MSG_Error_Header + "\r\n" +
  109.       "==================================================\r\n\r\n" +
  110.         errMsg;
  111.     // reset the _errorCount
  112.     errorCount = 0;
  113.     alert(fullMsg);
  114.     //alert(errMsg);
  115.   }
  116.   else if( errMsg == "" )
  117.   { // null == declined creating subdirectory    
  118.     window.close();
  119.   }
  120. }
  121.  
  122.  
  123. //--------------------------------------------------------------------
  124. // FUNCTION:
  125. //   cancelClicked
  126. //
  127. // DESCRIPTION:
  128. //   Called when the Cancel button is pressed.  Dismiss the dialog.
  129. //
  130. // ARGUMENTS:
  131. //   none
  132. //
  133. // RETURNS:
  134. //   nothing
  135. //--------------------------------------------------------------------
  136.  
  137. function cancelClicked()
  138. {
  139.   window.close();    
  140. }
  141.  
  142.  
  143. //--------------------------------------------------------------------
  144. // FUNCTION:
  145. //   displayHelp
  146. //
  147. // DESCRIPTION:
  148. //   Displays the built-in Dreamweaver help.
  149. //
  150. // ARGUMENTS:
  151. //   none
  152. //
  153. // RETURNS:
  154. //   nothing
  155. //--------------------------------------------------------------------
  156.  
  157. function displayHelp()
  158. {
  159.   // Replace the following call if you are modifying this file for your own use.
  160.   dwscripts.displayDWHelp(HELP_DOC);
  161. }
  162.  
  163.  
  164. // ***************** LOCAL FUNCTIONS  ******************
  165.  
  166. //--------------------------------------------------------------------
  167. // FUNCTION:
  168. //   initializeUI
  169. //
  170. // DESCRIPTION:
  171. //   Prepare the dialog and controls for user input
  172. //
  173. // ARGUMENTS:
  174. //   none
  175. //
  176. // RETURNS:
  177. //   nothing
  178. //--------------------------------------------------------------------
  179.  
  180. function initializeUI()
  181. {
  182.   // fill the array before the component section is initialized
  183.   LABEL_PARENT_CFCS = getParentCfcs();
  184.  
  185.   LABEL_CFC_ROOTS = getCfcRoots();
  186.   COMPONENT_INFO = new ComponentInfo();
  187.  
  188.   SECTION_LIST = new ListControl("section");  
  189.   SECTION_LIST.setAll(LABEL_SECTIONS, VALUE_SECTIONS);  
  190.   SECTION_LIST.setIndex(0);
  191.  
  192.   //Initialize the TabControl.  (Pass in the prefix used for the tab layers)
  193.   T = new TabControl('Tab');
  194.   //Add tab pages.   (Pass the layer name, and the page object)
  195.   T.addPage("componentSection", new ComponentsPage());
  196.   T.addPage("propertiesSection", new PropertiesPage());
  197.   T.addPage("methodsSection", new MethodsPage());
  198.   T.addPage("parametersSection", new ParametersPage());
  199.  
  200.   //Initialize the display.  Start with the selected page
  201.   T.start(SECTION_LIST.getValue());
  202.  
  203.   MM.CFCfileToOpen = "";
  204. }
  205.  
  206. //--------------------------------------------------------------------
  207. // FUNCTION:
  208. //   updateUI
  209. //
  210. // DESCRIPTION:
  211. //   Called by the main UI components to respond to events
  212. //
  213. // ARGUMENTS:
  214. //   theItemName - string - the name of the form control which
  215. //     generated the event
  216. //
  217. // RETURNS:
  218. //   nothing
  219. //--------------------------------------------------------------------
  220.  
  221. function updateUI(theItemName)
  222. {
  223.   if (theItemName == "section")
  224.   {
  225.     T.showPage(SECTION_LIST.getValue())
  226.   }
  227. }
  228.  
  229.  
  230. //--------------------------------------------------------------------
  231. // FUNCTION:
  232. //   saveToFile
  233. //
  234. // DESCRIPTION:
  235. //   Saves the current settings to the component file
  236. //
  237. // ARGUMENTS:
  238. //   none
  239. //
  240. // RETURNS:
  241. //   string - error message if any
  242. //--------------------------------------------------------------------
  243.  
  244. function saveToFile()
  245. {
  246.   var errMsg = "";
  247.   
  248.   // Get the file name
  249.   fileURL = getFileURL();
  250.  
  251.   // fileExists returns true for ""?
  252.   if ("" != fileURL)
  253.   {
  254.     if ( dwscripts.fileExists(fileURL))
  255.       {
  256.       // display confirmation message
  257.       if (!confirm(MSG_OverwriteExisting))
  258.       {
  259.         //return MSG_DeclinedOverwrite;
  260.         return null; // do not show error message if user doesn't want to overwrite
  261.       }
  262.     }
  263.   } else {
  264.     return null; // user declined creating subfolders?
  265.   }
  266.  
  267.   var fileOutput = new Array();
  268.   fileOutput.push( dwscripts.sprintf(LABEL_FileGeneratedBy, dw.appName, dw.appVersion, new Date()) );
  269.   fileOutput.push(COMPONENT_INFO.serialize());
  270.   
  271.   //alert(fileOutput.join(""));
  272.  
  273.   if (!dwscripts.setFileContents(fileURL, fileOutput.join("")))
  274.   {
  275.     errMsg = dwscripts.sprintf(MSG_FileWriteError,fileURL);
  276.   }
  277.   else
  278.   {
  279.      //  We don't want to actually open the CFC file here.  At first blush this might seem
  280.      //  like the right thing to do.  However, there is a problem if we try to do so.  That
  281.      //  problem concerns some very complicated stuff regarding edit ops and when to
  282.      //  suspend/continue them.  It is too complicated to explain here.  Suffice it to say
  283.      //  that the better way to do this is to set a variable here and let the caller
  284.      //  (in CFCs.js) do the actual opening of the document.
  285.  
  286.      MM.CFCfileToOpen = fileURL;
  287.   }
  288.   
  289.   return errMsg;
  290. }
  291.  
  292.  
  293. //--------------------------------------------------------------------
  294. // FUNCTION:
  295. //   saveToTemplate
  296. //
  297. // DESCRIPTION:
  298. //   Saves the current settings to a template
  299. //
  300. // ARGUMENTS:
  301. //   none
  302. //
  303. // RETURNS:
  304. //   string - error message if any
  305. //--------------------------------------------------------------------
  306.  
  307. function saveToTemplate()
  308. {
  309.   var errMsg = "";
  310.   
  311.   var fileOutput = new Array();
  312.   fileOutput.push( dwscripts.sprintf(LABEL_FileGeneratedBy, dw.appName, dw.appVersion, new Date()) );
  313.   fileOutput.push(COMPONENT_INFO.serialize());
  314.  
  315.   //alert(fileOutput.join(""));
  316.  
  317.   if (!dwscripts.setFileContents(TEMPLATE_URL, fileOutput.join("")))
  318.   {
  319.    errMsg = dwscripts.sprintf(MSG_FileWriteError,TEMPLATE_URL);
  320.   }
  321.   else
  322.   {
  323.     alert(MSG_TemplateSaved);
  324.   }
  325.   
  326.   return errMsg;
  327. }
  328.  
  329.  
  330. //--------------------------------------------------------------------
  331. // FUNCTION:
  332. //   loadFromTemplate
  333. //
  334. // DESCRIPTION:
  335. //   Reads in the component setting from a template
  336. //
  337. // ARGUMENTS:
  338. //   none
  339. //
  340. // RETURNS:
  341. //   boolean
  342. //--------------------------------------------------------------------
  343.  
  344. function loadFromTemplate()
  345. {
  346.   var retVal = false;
  347.   
  348.   if (dwscripts.fileExists(TEMPLATE_URL))
  349.   {  
  350.     var fileContents = dwscripts.getFileContents(TEMPLATE_URL);
  351.  
  352.     if (fileContents)
  353.     {
  354.       var retVal = COMPONENT_INFO.deserialize(fileContents);
  355.     }
  356.  
  357.     if (!retVal)
  358.     {
  359.       alert("ERROR parsing template file");
  360.     }
  361.   }
  362.   else
  363.   {
  364.     // alert template does not exist
  365.   }
  366.   
  367.   return retVal;
  368. }
  369.  
  370.  
  371. //--------------------------------------------------------------------
  372. // FUNCTION:
  373. //   getFileURL
  374. //
  375. // DESCRIPTION:
  376. //   Returns the full URL for the current component file
  377. //
  378. // ARGUMENTS:
  379. //   none
  380. //
  381. // RETURNS:
  382. //   string
  383. //--------------------------------------------------------------------
  384.  
  385. function getFileURL()
  386. {
  387.   var retVal = "";
  388.   
  389.   if (FILE_DIR && COMPONENT_INFO.name)
  390.   {
  391.     if( normalizedDirectory() )
  392.     {
  393.       retVal = FILE_DIR + COMPONENT_INFO.name + ".cfc";
  394.     }
  395.     
  396.   }
  397.   
  398.   return retVal;
  399. }
  400.  
  401. //--------------------------------------------------------------------
  402. // FUNCTION:
  403. //   normalizedDirectory
  404. //
  405. // DESCRIPTION:
  406. //   - converts the FILE_DIR to Local URL
  407. //   - appends BACK_SLASH or FORWARD_SLASH as necessary
  408. //   - confirms creation of non-existent subdirectories
  409. //
  410. // ARGUMENTS:
  411. //   none
  412. //
  413. // RETURNS:
  414. //   boolean if nothing went wrong
  415. //--------------------------------------------------------------------
  416.  
  417. function normalizedDirectory() {
  418.   var originalDirectory = FILE_DIR;
  419.   var directory = dwscripts.filePathToLocalURL(FILE_DIR);
  420.   var lastChar = directory.charAt(directory.length-1);
  421.  
  422.   if( lastChar != FORWARD_SLASH && lastChar != BACK_SLASH )
  423.   {
  424.     // attempt to find the appropriate slash to use
  425.     if( directory.indexOf(BACK_SLASH) > -1 )
  426.     {
  427.       directory += BACK_SLASH;
  428.     } 
  429.     else
  430.     {
  431.       directory += FORWARD_SLASH;
  432.     }
  433.   }
  434.   FILE_DIR = directory;
  435.  
  436.   // confirm with the user to create non-existent directories
  437.   if( !DWfile.exists(directory) )
  438.   {
  439.     if( confirm( dwscripts.sprintf(MSG_CreateDirectory, originalDirectory) ) )
  440.     {
  441.      //DWfile.createFolder(compFileDir);
  442.       return createFolder(directory);
  443.     }
  444.     else
  445.     {
  446.       return false;
  447.     }
  448.   }
  449.   return true;
  450. }
  451.  
  452. //--------------------------------------------------------------------
  453. // FUNCTION:
  454. //   createFolder
  455. //
  456. // DESCRIPTION:
  457. //   - cut and pasted from Configuration/WebServices/ProxyGenerators/DefaultProxyGen.js
  458. //   - doesn't work with multiple subdirectories when using UNC path of \\compname\compdir
  459. //
  460. // ARGUMENTS:
  461. //   folderURL - the full folder URL
  462. //
  463. // RETURNS:
  464. //   boolean if nothing went wrong
  465. //--------------------------------------------------------------------
  466. function createFolder(folderURL)
  467. {
  468.   var fileFolderURL = MMNotes.localURLToFilePath(folderURL);
  469.   if (fileFolderURL)
  470.   {
  471.     var start = 0, index = -1, nextindex = -1, folder;
  472.     while (index < fileFolderURL.length)
  473.     {
  474.       index = ((fileFolderURL.indexOf("\\", start)) || (fileFolderURL.indexOf("/", start)));
  475.       if (index != -1)
  476.       {
  477.         folder = fileFolderURL.substr(0, index);
  478.         if (!DWfile.exists(MMNotes.filePathToLocalURL(folder)))
  479.         {
  480.           if (DWfile.createFolder(MMNotes.filePathToLocalURL(folder)))
  481.           {
  482.             start = index + 1;
  483.           }
  484.           else  
  485.             return false;
  486.         }
  487.         else
  488.         {
  489.           start = index + 1;
  490.         }
  491.       } // index != -1
  492.       else
  493.       {
  494.         folder = fileFolderURL;
  495.         if (!DWfile.exists(MMNotes.filePathToLocalURL(folder)))
  496.         {
  497.           if (!DWfile.createFolder(MMNotes.filePathToLocalURL(folder)))
  498.             return false;
  499.           else
  500.             return true;  
  501.         }
  502.         else
  503.           break;  
  504.       }
  505.     } // while
  506.   }
  507.   return true;
  508. }
  509.  
  510. //--------------------------------------------------------------------
  511. // FUNCTION:
  512. //   getUniqueName
  513. //
  514. // DESCRIPTION:
  515. //   Returns a unique name based on the given prefix, and an array
  516. //   of names that already exist.
  517. //
  518. //   If the label is unique, then it is returned with no suffix.
  519. //   If it is not unique, then the next unique name is found.
  520. //
  521. // ARGUMENTS:
  522. //   prefix - string - the base name to use
  523. //   arrayToSearch - array of objects with name property - the array
  524. //     of objects to search for duplicate names
  525. //
  526. // RETURNS:
  527. //   string
  528. //--------------------------------------------------------------------
  529.  
  530. function getUniqueName(prefix, arrayToSearch)
  531. {
  532.   var retVal = prefix;
  533.   var count = 0;
  534.   
  535.   if (arrayToSearch != null && arrayToSearch.length > 0)
  536.   {
  537.     var matchFn = new Function("object,searchValue", "return (object.name == searchValue);");
  538.  
  539.     while (dwscripts.findInArray(arrayToSearch,retVal,matchFn) != -1)
  540.     {
  541.       count++;
  542.       retVal = prefix + count.toString();
  543.     }
  544.   }
  545.   
  546.   return retVal;
  547. }
  548.  
  549.  
  550. //--------------------------------------------------------------------
  551. // FUNCTION:
  552. //   containsInvalidChars
  553. //
  554. // DESCRIPTION:
  555. //   Returns true if the given string contains invalid characters
  556. //
  557. // ARGUMENTS:
  558. //   str - string - the string to check
  559. //
  560. // RETURNS:
  561. //   boolean
  562. //--------------------------------------------------------------------
  563.  
  564. function containsInvalidChars(str)
  565. {
  566.   var retVal = false;
  567.   
  568.   if (str) 
  569.   {
  570.     var regExp = /[^\w\d]/g; // new in JS 1.5, \w will support special characters 
  571.     
  572.     retVal = (str.search(regExp) != -1);
  573.   }
  574.   
  575.   return retVal;
  576. }
  577.  
  578.  
  579. //--------------------------------------------------------------------
  580. // FUNCTION:
  581. //   createFolders
  582. //
  583. // DESCRIPTION:
  584. //   Recursively creates folders for the given file URL
  585. //
  586. // ARGUMENTS:
  587. //   fileURL - string - the URL path of the folder to create
  588. //
  589. // RETURNS:
  590. //   boolean - true if successfull
  591. //--------------------------------------------------------------------
  592.  
  593. function createFolders(fileURL)
  594. {
  595.   var retVal = true;
  596.   
  597.   if (!dwscripts.fileExists(fileURL))
  598.   {
  599.     var parentURL = dwscripts.getAbsoluteParentURL();
  600.     
  601.     if (createFolders(parentURL))
  602.     {
  603.       retVal = dwscripts.createFolder(fileURL);
  604.     }
  605.     else
  606.     {
  607.       retVal = false;
  608.     }
  609.   }
  610.   
  611.   return retVal;
  612. }
  613.  
  614.  
  615.  
  616. //--------------------------------------------------------------------
  617. // CLASS:
  618. //   ComponentInfo
  619. //
  620. // DESCRIPTION:
  621. //   This class represents the information about a component
  622. //
  623. // PUBLIC PROPERTIES:
  624. //
  625. //   name
  626. //   displayName
  627. //   description
  628. //   parent
  629. //     
  630. //   properties
  631. //   methods
  632. //
  633. //   fileDir    
  634. //
  635. // PUBLIC FUNCTIONS:
  636. //
  637. //   serialize()
  638. //   validate()
  639. //   getFileURL()
  640. //
  641. //--------------------------------------------------------------------
  642.  
  643. function ComponentInfo()
  644. {
  645.   this.name = "";
  646.   this.displayName = "";
  647.   this.description = "";
  648.   this.parent = "";
  649.   
  650.   this.properties = new Array();  // array of property info
  651.   
  652.   this.methods = new Array();
  653. }
  654.  
  655. ComponentInfo.prototype.serialize = ComponentInfo_serialize;
  656. ComponentInfo.prototype.serializeToTagEdit = ComponentInfo_serializeToTagEdit;
  657. ComponentInfo.prototype.deserialize = ComponentInfo_deserialize;
  658. ComponentInfo.prototype.validate = ComponentInfo_validate;
  659.  
  660.  
  661. function ComponentInfo_serialize()
  662. {
  663.   var componentTag = this.serializeToTagEdit();
  664.   
  665.   componentTag.format("\t");
  666.   
  667.   return componentTag.getOuterHTML();
  668. }
  669.  
  670.  
  671. function ComponentInfo_serializeToTagEdit(tagToSet)
  672. {
  673.   var componentTag = null;
  674.   if (tagToSet)
  675.   {
  676.     componentTag = tagToSet;
  677.   }
  678.   else
  679.   {    
  680.     componentTag = new TagEdit("<cfcomponent></cfcomponent>");
  681.   }
  682.   
  683.   // componentTag.setAttribute("name", this.name);
  684.   if (this.displayName)
  685.   {
  686.     componentTag.setAttribute("displayName", this.displayName);
  687.   }
  688.   if (this.description)
  689.   {
  690.     componentTag.setAttribute("hint", this.description);
  691.   }
  692.   if (this.parent)
  693.   {
  694.     componentTag.setAttribute("extends", this.parent);
  695.   }
  696.   
  697.   var childNodes = new Array();
  698.   
  699.   for (var i=0; i < this.properties.length; i++)
  700.   {
  701.     childNodes.push(this.properties[i].serializeToTagEdit());
  702.   }
  703.   
  704.   for (var i=0; i < this.methods.length; i++)
  705.   {
  706.     childNodes.push(this.methods[i].serializeToTagEdit());
  707.   }
  708.  
  709.   componentTag.setChildNodes(childNodes);
  710.  
  711.   return componentTag;  
  712. }
  713.  
  714.  
  715. function ComponentInfo_deserialize(tagSource)
  716. {
  717.   var retVal = false;
  718.  
  719.   var componentTag = null;
  720.   
  721.   if (typeof tagSource == "string")
  722.   {
  723.     // use the tag edit class to read out the properties
  724.     var tagList = TagEdit.parseString(tagSource);
  725.  
  726.     // set the componentTag
  727.     var componentTag = null;
  728.     if (tagList)
  729.     {
  730.       for (var i=0; i < tagList.length; i++)
  731.       {
  732.         if (tagList[i].getTagName() == "CFCOMPONENT")
  733.         {
  734.           componentTag = tagList[i];
  735.           break;
  736.         }
  737.       }
  738.     }
  739.   }
  740.   else
  741.   {
  742.     componentTag = tagSource;
  743.   }
  744.   
  745.   
  746.     
  747.   if (componentTag)
  748.   {
  749.     retVal = true;
  750.     
  751.     this.name = componentTag.getAttribute("name");
  752.     this.displayName = componentTag.getAttribute("displayName");
  753.     this.description = componentTag.getAttribute("hint");
  754.     this.parent = componentTag.getAttribute("parentDescriptor");
  755.     
  756.     var childNodes = componentTag.getChildNodes();
  757.     
  758.     this.properties = new Array();
  759.     this.methods = new Array();
  760.     
  761.     // get the properties and methods
  762.     for (var i=0; i < childNodes.length; i++)
  763.     {
  764.       if (childNodes[i].getTagName() == "CFPROPERTY")
  765.       {
  766.         var node = new PropertyInfo();
  767.         var result = node.deserialize(childNodes[i]);
  768.         if (result)
  769.         {
  770.           this.properties.push(node);
  771.         }
  772.         else
  773.         {
  774.           alert("ERROR parsing property:\n" +  childNodes[i].toString());
  775.           retVal = false;
  776.         }
  777.       }
  778.       else if (childNodes[i].getTagName() == "CFFUNCTION")
  779.       {
  780.         var node = new MethodInfo();
  781.         var result = node.deserialize(childNodes[i]);
  782.         if (result)
  783.         {
  784.           this.methods.push(node);
  785.         }
  786.         else
  787.         {
  788.           alert("ERROR parsing method:\n" +  childNodes[i].toString());
  789.           retVal = false;
  790.         }
  791.       }
  792.     }
  793.     
  794.     this.name = (this.name != null) ? this.name : "";
  795.     this.displayName = (this.displayName != null) ? this.displayName : "";
  796.     this.description = (this.description != null) ? this.description : "";
  797.     this.parent = (this.parent != null) ? this.parent : "";
  798.   }
  799.   else
  800.   {
  801.     alert("Error: Component tag not found");
  802.   }
  803.  
  804.   return retVal;
  805. }
  806.  
  807.  
  808. function ComponentInfo_validate()
  809. {
  810.   var retVal = new Array();  // use arrays for string concatenation, not +=
  811.   if( "" == this.name  || containsInvalidChars(this.name) ) {
  812.     retVal.push(++errorCount + ". " + dwscripts.sprintf(MSG_Error_BlankName, LABEL_Component));
  813.   }
  814.   if( "" == FILE_DIR ) {
  815.     retVal.push(++errorCount + MSG_Error_CompFileOutputDir);
  816.   }
  817.     
  818.   for (var i=0; i < this.properties.length; i++)
  819.   {
  820.     retVal.push(this.properties[i].validate());
  821.   }
  822.   
  823.   for (var i=0; i < this.methods.length; i++)
  824.   {
  825.     retVal.push(this.methods[i].validate());
  826.   }
  827.  
  828.   return retVal.join("");
  829. }
  830.  
  831.  
  832. //--------------------------------------------------------------------
  833. // CLASS:
  834. //   PropertyInfo
  835. //
  836. // DESCRIPTION:
  837. //   This class represents the information about a property
  838. //
  839. // PUBLIC PROPERTIES:
  840. //
  841. //   name
  842. //   displayName
  843. //   access
  844. //   type
  845. //   isArray
  846. //   description
  847. //   defaultValue
  848. //   required
  849. //   searchable
  850. //   fullText
  851. //
  852. // PUBLIC FUNCTIONS:
  853. //
  854. //   serialize()
  855. //   validate()
  856. //
  857. //--------------------------------------------------------------------
  858.  
  859. function PropertyInfo()
  860. {
  861.   this.name = "";
  862.   this.displayName = "";
  863.   this.access = "public";
  864.   this.type = "string";
  865.   this.isArray = false;
  866.   this.description = "";
  867.   this.defaultValue = "";
  868.   this.required = false;
  869.   this.searchable = false;
  870.   this.fullText = false;
  871. }
  872.  
  873. PropertyInfo.prototype.serialize = PropertyInfo_serialize;
  874. PropertyInfo.prototype.serializeToTagEdit = PropertyInfo_serializeToTagEdit;
  875. PropertyInfo.prototype.deserialize = PropertyInfo_deserialize;
  876. PropertyInfo.prototype.validate = PropertyInfo_validate;
  877.  
  878.  
  879. function PropertyInfo_serialize()
  880. {
  881.   var propertyTag = this.serializeToTagEdit();
  882.   
  883.   propertyTag.format("\t");
  884.   
  885.   return propertyTag.getOuterHTML();
  886. }
  887.  
  888.  
  889. function PropertyInfo_serializeToTagEdit(tagToSet)
  890. {
  891.   var propertyTag = null
  892.   if (tagToSet)
  893.   {
  894.     propertyTag = tagToSet;
  895.   }
  896.   else
  897.   {
  898.     propertyTag = new TagEdit("<cfproperty>");
  899.   }
  900.   
  901.   propertyTag.setAttribute("name", this.name);
  902.   if (this.displayName)
  903.   {
  904.     propertyTag.setAttribute("displayName", this.displayName);
  905.   }
  906.   if  (this.description)
  907.   {
  908.     propertyTag.setAttribute("hint", this.description);
  909.   }
  910.   //propertyTag.setAttribute("access", this.access);
  911.   propertyTag.setAttribute("type" , this.type);
  912.   if (this.defaultValue)
  913.   {
  914.     propertyTag.setAttribute("default" , this.defaultValue);
  915.   }
  916.   if (this.required)
  917.   {
  918.     propertyTag.setAttribute("required" , this.required);
  919.   }
  920.   if (this.searchable)
  921.   {
  922.     propertyTag.setAttribute("searchable" , this.searchable);
  923.   }
  924.   if (this.fullText)
  925.   {
  926.     propertyTag.setAttribute("fullText" , this.fullText);
  927.   }
  928.   
  929.   return propertyTag;
  930. }
  931.  
  932.  
  933. function PropertyInfo_deserialize(tagSource)
  934. {
  935.   var retVal = false;
  936.   
  937.   var propertyTag = null;
  938.   
  939.   if (typeof tagSource == "string")
  940.   {
  941.     // use the tag edit class to read out the properties
  942.     var tagList = TagEdit.parseString(tagSource);
  943.  
  944.     // set the propertyTag
  945.     if (tagList)
  946.     {
  947.       for (var i=0; i < tagList.length; i++)
  948.       {
  949.         if (tagList[i].getTagName() == "CFPROPERTY")
  950.         {
  951.           propertyTag = tagList[i];
  952.           break;
  953.         }
  954.       }
  955.     }
  956.   }
  957.   else
  958.   {
  959.     propertyTag = tagSource;
  960.   }
  961.   
  962.   if (propertyTag)
  963.   {
  964.     retVal = true;
  965.  
  966.     this.name = propertyTag.getAttribute("name");
  967.     this.displayName = propertyTag.getAttribute("displayName");
  968.     this.description = propertyTag.getAttribute("hint");
  969.     this.access = propertyTag.getAttribute("access");
  970.     this.type = propertyTag.getAttribute("type");
  971.     this.defaultValue = propertyTag.getAttribute("default");
  972.     this.required = (propertyTag.getAttribute("required") == "true");
  973.     this.searchable = (propertyTag.getAttribute("searchable") == "true");
  974.     this.fullText = propertyTag.getAttribute("fullText");
  975.     
  976.     this.name = (this.name != null) ? this.name : "";
  977.     this.displayName = (this.displayName != null) ? this.displayName : "";
  978.     this.description = (this.description != null) ? this.description : "";
  979.     this.access = (this.access != null) ? this.access : "public";
  980.     this.type = (this.type != null) ? this.type : "string";
  981.     this.defaultValue = (this.defaultValue != null) ? this.defaultValue : "";
  982.     this.fullText = (this.fullText != null) ? this.fullText : "";
  983.   }
  984.   
  985.   return retVal;
  986. }
  987.  
  988.  
  989. function PropertyInfo_validate()
  990. {
  991.   var retVal = new Array();  // use arrays for string concatenation, not +=
  992.   
  993.   return retVal.join("");
  994. }
  995.  
  996.  
  997. //--------------------------------------------------------------------
  998. // CLASS:
  999. //   MethodInfo
  1000. //
  1001. // DESCRIPTION:
  1002. //   This class represents information about a method
  1003. //
  1004. // PUBLIC PROPERTIES:
  1005. //
  1006. //   name
  1007. //   displayName
  1008. //   description
  1009. //   access
  1010. //   isStatic
  1011. //   resultType
  1012. //   output
  1013. //     
  1014. //   parameters
  1015. //
  1016. // PUBLIC FUNCTIONS:
  1017. //   
  1018. //   serialize()
  1019. //   validate()
  1020. //
  1021. //--------------------------------------------------------------------
  1022.  
  1023. function MethodInfo()
  1024. {
  1025.   this.name = "";
  1026.   this.displayName = "";
  1027.   this.description = "";
  1028.   this.access = "public";
  1029.   this.roles = "";
  1030.   this.isStatic = false;
  1031.   this.resultType = "";
  1032.   this.output = false;
  1033.   
  1034.   this.parameters = new Array(); // array of parameter info
  1035. }
  1036.  
  1037. MethodInfo.prototype.serialize = MethodInfo_serialize;
  1038. MethodInfo.prototype.serializeToTagEdit = MethodInfo_serializeToTagEdit;
  1039. MethodInfo.prototype.deserialize = MethodInfo_deserialize;
  1040. MethodInfo.prototype.validate = MethodInfo_validate;
  1041.  
  1042.  
  1043. function MethodInfo_serialize()
  1044. {
  1045.   var methodTag = this.serializeToTagEdit();
  1046.   
  1047.   methodTag.format("\t");
  1048.   
  1049.   return methodTag.getOuterHTML();
  1050. }
  1051.  
  1052.  
  1053. function MethodInfo_serializeToTagEdit(tagToSet)
  1054. {
  1055.   var methodTag = null;
  1056.   if (tagToSet)
  1057.   {
  1058.     methodTag = tagToSet;
  1059.   }
  1060.   else
  1061.   {
  1062.     methodTag = new TagEdit("<cffunction></cffunction>");
  1063.   }
  1064.   
  1065.   methodTag.setAttribute("name", this.name);
  1066.   var retVal = new Array();  
  1067.   if (this.displayName)
  1068.   {
  1069.     methodTag.setAttribute("displayName", this.displayName);
  1070.   }
  1071.   if (this.description)
  1072.   {
  1073.     methodTag.setAttribute("hint", this.description);
  1074.   }
  1075.   methodTag.setAttribute("access", this.access);
  1076.   //methodTag.setAttribute("static", this.isStatic);
  1077.   if (this.roles)
  1078.   {
  1079.     methodTag.setAttribute("roles", this.roles);
  1080.   }
  1081.   if (this.resultType)
  1082.   {
  1083.     methodTag.setAttribute("returnType", this.resultType);
  1084.   }
  1085.   methodTag.setAttribute("output", this.output.toString());
  1086.   
  1087.   var paramNodes = new Array();
  1088.   for (var i=0; i < this.parameters.length; i++)
  1089.   {
  1090.     paramNodes.push(this.parameters[i].serializeToTagEdit());
  1091.   }
  1092.   var childNodes = paramNodes;  
  1093.   var cffunctionComment = new TagEdit("\r\n\r\n<!--- " + this.name + " body --->");
  1094.   childNodes.push(cffunctionComment);
  1095.  
  1096.   if (this.resultType && "none" != this.resultType)
  1097.   {
  1098.     var cfreturnNode = new TagEdit("\r\n\r\n<cfreturn >");
  1099.     childNodes.push(cfreturnNode);
  1100.   }
  1101.  
  1102.   methodTag.setChildNodes(childNodes);
  1103.   
  1104.   return methodTag;
  1105. }
  1106.  
  1107.  
  1108. function MethodInfo_deserialize(tagSource)
  1109. {
  1110.   var retVal = false;
  1111.   
  1112.   var methodTag = null;
  1113.   
  1114.   if (typeof tagSource == "string")
  1115.   {
  1116.     // use the tag edit class to read out the properties
  1117.     var tagList = TagEdit.parseString(tagSource);
  1118.  
  1119.     // set the propertyTag
  1120.     if (tagList)
  1121.     {
  1122.       for (var i=0; i < tagList.length; i++)
  1123.       {
  1124.         if (tagList[i].getTagName() == "CFFUNCTION")
  1125.         {
  1126.           methodTag = tagList[i];
  1127.           break;
  1128.         }
  1129.       }
  1130.     }
  1131.   }
  1132.   else
  1133.   {
  1134.     methodTag = tagSource;
  1135.   }
  1136.   
  1137.   if (methodTag)
  1138.   {
  1139.     retVal = true;
  1140.     
  1141.     this.name = methodTag.getAttribute("name");
  1142.     this.displayName = methodTag.getAttribute("displayName");
  1143.     this.description = methodTag.getAttribute("hint");
  1144.     this.access = methodTag.getAttribute("access");
  1145.     this.roles = methodTag.getAttribute("roles");
  1146.     //this.isStatic = (methodTag.getAttribute("static") == "true");
  1147.     this.resultType = methodTag.getAttribute("returnType");
  1148.     this.output = (methodTag.getAttribute("output") == "true");
  1149.     
  1150.     var childNodes = methodTag.getChildNodes();
  1151.  
  1152.     this.parameters = new Array();
  1153.     
  1154.     // get the parameters
  1155.     for (var i=0; i < childNodes.length; i++)
  1156.     {
  1157.       if (childNodes[i].getTagName() == "CFARGUMENT")
  1158.       {
  1159.         var node = new ParameterInfo();
  1160.         var result = node.deserialize(childNodes[i]);
  1161.         if (result)
  1162.         {
  1163.           this.parameters.push(node);
  1164.         }
  1165.         else
  1166.         {
  1167.           retVal = false;
  1168.         }
  1169.       }
  1170.     }
  1171.  
  1172.     this.name = (this.name != null) ? this.name : "";
  1173.     this.displayName = (this.displayName != null) ? this.displayName : "";
  1174.     this.description = (this.description != null) ? this.description : "";
  1175.     this.access = (this.access != null) ? this.access : "";
  1176.     this.roles = (this.roles != null) ? this.roles : "";
  1177.     this.resultType = (this.resultType != null) ? this.resultType : "";
  1178.   }
  1179.   
  1180.   return retVal;
  1181. }
  1182.  
  1183.  
  1184. function MethodInfo_validate()
  1185. {
  1186.   var retVal = new Array();  // use arrays for string concatenation, not +=
  1187.   
  1188.   for (var i=0; i < this.parameters.length; i++)
  1189.   {
  1190.     retVal.push(this.parameters[i].validate());
  1191.   }
  1192.   
  1193.   return retVal.join("");
  1194. }
  1195.  
  1196.  
  1197. //--------------------------------------------------------------------
  1198. // CLASS:
  1199. //   ParameterInfo
  1200. //
  1201. // DESCRIPTION:
  1202. //   This class represent information about a parameter
  1203. //
  1204. // PUBLIC PROPERTIES:
  1205. //
  1206. //   name
  1207. //   displayName
  1208. //   description
  1209. //   type
  1210. //   required
  1211. //   defaultValue
  1212. //
  1213. // PUBLIC FUNCTIONS:
  1214. //
  1215. //   serialize()
  1216. //   validate()
  1217. //
  1218. //--------------------------------------------------------------------
  1219.  
  1220. function ParameterInfo()
  1221. {
  1222.   this.name = "";
  1223.   this.displayName = "";
  1224.   this.description = "";
  1225.   this.type = "string";
  1226.   this.required = false;
  1227.   this.defaultValue = "";
  1228. }
  1229.  
  1230. ParameterInfo.prototype.serialize = ParameterInfo_serialize;
  1231. ParameterInfo.prototype.serializeToTagEdit = ParameterInfo_serializeToTagEdit;
  1232. ParameterInfo.prototype.deserialize = ParameterInfo_deserialize;
  1233. ParameterInfo.prototype.validate = ParameterInfo_validate;
  1234.  
  1235.  
  1236. function ParameterInfo_serialize()
  1237. {
  1238.   var parameterTag = this.serializeToTagEdit();
  1239.   
  1240.   parameterTag.format("\t");
  1241.   
  1242.   return parameterTag.getOuterHTML();
  1243. }
  1244.  
  1245.  
  1246. function ParameterInfo_serializeToTagEdit(tagToSet)
  1247. {
  1248.   var parameterTag = null;
  1249.   if (tagToSet)
  1250.   {
  1251.     parameterTag = tagToSet;
  1252.   }
  1253.   else
  1254.   {
  1255.     parameterTag = new TagEdit("<cfargument>");
  1256.   }
  1257.   
  1258.   parameterTag.setAttribute("name", this.name);
  1259.   if (this.displayName)
  1260.   {
  1261.     parameterTag.setAttribute("displayName", this.displayName);
  1262.   }
  1263.   if (this.description)
  1264.   {
  1265.     parameterTag.setAttribute("hint", this.description);
  1266.   }
  1267.   parameterTag.setAttribute("type", this.type + ((this.isArray) ? '[]' : ''));
  1268.   if (this.required)
  1269.   {
  1270.     parameterTag.setAttribute("required", this.required);
  1271.   }
  1272.   if (this.defaultValue)
  1273.   {
  1274.     parameterTag.setAttribute("default", this.defaultValue);
  1275.   }
  1276.   
  1277.   return parameterTag;
  1278. }
  1279.  
  1280. function ParameterInfo_deserialize(tagSource)
  1281. {
  1282.   var retVal = false;
  1283.   
  1284.   var parameterTag = null;
  1285.   
  1286.   if (typeof tagSource == "string")
  1287.   {
  1288.     // use the tag edit class to read out the properties
  1289.     var tagList = TagEdit.parseString(tagSource);
  1290.  
  1291.     // set the parameterTag
  1292.     if (tagList)
  1293.     {
  1294.       for (var i=0; i < tagList.length; i++)
  1295.       {
  1296.         if (tagList[i].getTagName() == "CFARGUMENT")
  1297.         {
  1298.           parameterTag = tagList[i];
  1299.           break;
  1300.         }
  1301.       }
  1302.     }
  1303.   }
  1304.   else
  1305.   {
  1306.     parameterTag = tagSource;
  1307.   }
  1308.   
  1309.   if (parameterTag)
  1310.   {
  1311.     retVal = true;
  1312.     
  1313.     this.name = parameterTag.getAttribute("name");
  1314.     this.displayName = parameterTag.getAttribute("displayName");
  1315.     this.description = parameterTag.getAttribute("hint");
  1316.     this.type = parameterTag.getAttribute("type");
  1317.     this.required = (parameterTag.getAttribute("required") == "true");
  1318.     this.defaultValue = parameterTag.getAttribute("default");
  1319.     
  1320.     this.name = (this.name != null) ? this.name : "";
  1321.     this.displayName = (this.displayName != null) ? this.displayName : "";
  1322.     this.description = (this.description != null) ? this.description : "";
  1323.     this.type = (this.type != null) ? this.type : "string";
  1324.     this.defaultValue = (this.defaultValue != null) ? this.defaultValue : "";
  1325.   }
  1326.   
  1327.   return retVal;
  1328. }
  1329.  
  1330.  
  1331. function ParameterInfo_validate()
  1332. {
  1333.   var retVal = new Array();  // use arrays for string concatenation, not +=
  1334.   
  1335.   return retVal.join("");
  1336. }
  1337.  
  1338.  
  1339.  
  1340. //--------------------------------------------------------------------
  1341. // Page Classes
  1342. // 
  1343. //  Please see the TabControlClass.js file in Shared/MM/Scripts/Class
  1344. //  for more information on the functions defined within these classes
  1345. //
  1346. //--------------------------------------------------------------------
  1347.  
  1348.  
  1349.  
  1350.  
  1351. //--------------------------------------------------------------------
  1352. // CLASS:
  1353. //   ComponentsPage
  1354. //
  1355. // DESCRIPTION:
  1356. //   This class handles the display and update of the component page
  1357. //
  1358. // PUBLIC PROPERTIES:
  1359. //   NONE
  1360. //
  1361. // PUBLIC FUNCTIONS:
  1362. //   NONE
  1363. //
  1364. //--------------------------------------------------------------------
  1365.  
  1366. function ComponentsPage(theTabLabel)
  1367. {
  1368.   this.tabLabel = theTabLabel;
  1369.   
  1370.   // controls
  1371.   this.compName = "";
  1372.   this.compDisplayName = "";
  1373.   this.compDescription = "";
  1374.   this.compParent = "";
  1375.   this.compFileOutputDir = "";
  1376. }
  1377.  
  1378. ComponentsPage.prototype.getTabLabel = ComponentsPage_getTabLabel;
  1379. ComponentsPage.prototype.canLoad = ComponentsPage_canLoad;
  1380. ComponentsPage.prototype.load = ComponentsPage_load;
  1381. ComponentsPage.prototype.update = ComponentsPage_update;
  1382. ComponentsPage.prototype.unload = ComponentsPage_unload;
  1383. ComponentsPage.prototype.lastUnload = ComponentsPage_lastUnload;
  1384.  
  1385. function ComponentsPage_getTabLabel()
  1386. {
  1387.   return this.tabLabel;
  1388. }
  1389.  
  1390. //Called to check if a page can be loaded
  1391. //
  1392. function ComponentsPage_canLoad()
  1393. {
  1394.   //alert("canLoad() called " + this.tabLabel);
  1395.   return true;
  1396. }
  1397.  
  1398. //Called when the layer for this page is displayed.
  1399. // Use this call to initialize controls.
  1400. //
  1401. function ComponentsPage_load()
  1402. {
  1403.   //alert("load() called " + this.tabLabel + " (loaded = " + this.loaded + ")");
  1404.   this.compName = dwscripts.findDOMObject("compName");
  1405.   this.compDisplayName = dwscripts.findDOMObject("compDisplayName");
  1406.   this.compDescription = dwscripts.findDOMObject("compDescription");
  1407.   this.compParent = new ListControl("compParent");
  1408.   this.compFileOutputDir = new ListControl("compFileOutputDir");
  1409.  
  1410.   this.compParent.setAll(LABEL_PARENT_CFCS,LABEL_PARENT_CFCS);
  1411.   this.compFileOutputDir.setAll(LABEL_CFC_ROOTS,LABEL_CFC_ROOTS);
  1412.  
  1413.   this.update("refresh");
  1414. }
  1415.  
  1416. //Called when one of the page controls calls the tabControl update function.
  1417. // Use this call to respond to user input.
  1418. //
  1419. function ComponentsPage_update(theItemName)
  1420. {
  1421.   //alert("update() called for " + theItemName + " on " + this.tabLabel);
  1422.   
  1423.   if (theItemName == "refresh")
  1424.   {
  1425.     this.compName.value = COMPONENT_INFO.name;
  1426.     this.compDisplayName.value = COMPONENT_INFO.displayName;
  1427.     this.compDescription.value = COMPONENT_INFO.description;
  1428.     this.compParent.pick(COMPONENT_INFO.parent);
  1429.     this.compFileOutputDir.set(FILE_DIR,-1);
  1430.   }
  1431.  
  1432.   if (theItemName == "compName")
  1433.   {
  1434.     COMPONENT_INFO.name = this.compName.value;
  1435.   }
  1436.   else if (theItemName == "compDisplayName")
  1437.   {
  1438.     COMPONENT_INFO.displayName = this.compDisplayName.value;
  1439.   }
  1440.   else if (theItemName == "compDescription")
  1441.   {
  1442.     COMPONENT_INFO.description = this.compDescription.value;
  1443.   } 
  1444.   else if (theItemName == "compParent")
  1445.   {
  1446.     COMPONENT_INFO.parent = this.compParent.getValue();
  1447.   } 
  1448.   else if (theItemName == "FolderBrowse")
  1449.   {
  1450.     retVal = dwscripts.localURLToFilePath(dreamweaver.browseForFolderURL(LABEL_DirBrowse));
  1451.     if (retVal)
  1452.     {
  1453.       // need the optional index of -1 so it doesn't override the selectedIndex
  1454.       this.compFileOutputDir.set(retVal,-1);
  1455.     }
  1456.   }
  1457.   else if (theItemName == "saveToTemplate")
  1458.   {
  1459.     saveToTemplate();
  1460.   }
  1461.   else if (theItemName == "loadFromTemplate")
  1462.   {
  1463.     loadFromTemplate();
  1464.     this.update("refresh");
  1465.   }
  1466. }
  1467.  
  1468. //Called when another page is about to be shown, or finish() is called on
  1469. // the tabControl.  Use this call to perform any finishing tasks.
  1470. //
  1471. function ComponentsPage_unload()
  1472. {
  1473.   //alert("unload() called " + this.tabLabel);
  1474.   
  1475.   COMPONENT_INFO.name = this.compName.value;
  1476.   COMPONENT_INFO.displayName = this.compDisplayName.value;
  1477.   COMPONENT_INFO.description = this.compDescription.value;
  1478.   COMPONENT_INFO.parent = this.compParent.get();
  1479.   FILE_DIR = this.compFileOutputDir.get();
  1480.   
  1481.   // do any checking needed while changing pages.
  1482.   // return false if we should remain on this page.
  1483.  
  1484.   // hack to make sure that controls disappear correctly
  1485.   T.obj.visibility = "hidden";
  1486.   T.obj.visibility = "visible";
  1487.     
  1488.   return true;
  1489. }
  1490.  
  1491. //Called when finish() is called on the tabControl.
  1492. // Use this call to perform any last minute page updates.
  1493. //
  1494. function ComponentsPage_lastUnload()
  1495. {
  1496.   //alert("lastUnload() called " + this.tabLabel);
  1497.   return true;
  1498. }
  1499.  
  1500.  
  1501.  
  1502.  
  1503. //--------------------------------------------------------------------
  1504. // CLASS:
  1505. //   PropertiesPage
  1506. //
  1507. // DESCRIPTION:
  1508. //   This class handles the display and update of the properties page
  1509. //
  1510. // PUBLIC PROPERTIES:
  1511. //   NONE
  1512. //
  1513. // PUBLIC FUNCTIONS:
  1514. //   NONE
  1515. //
  1516. //--------------------------------------------------------------------
  1517.  
  1518. function PropertiesPage(theTabLabel)
  1519. {
  1520.   this.tabLabel = theTabLabel;
  1521.   
  1522.   this.properties = "";
  1523.   this.propName = "";
  1524.   this.propDisplayName = "";
  1525.   this.propDescription = "";
  1526.   //this.propAccess = "";
  1527.   this.propType = "";
  1528.   this.propArray = ""; 
  1529.   //this.propDefaultValue = "";
  1530.   //this.propRequired = "";
  1531.   this.propSearchable = "";
  1532.   this.propFullText = "";
  1533.  
  1534.   this.selectedProperty = -1;
  1535.   
  1536.   this.pageIsEnabled = true;
  1537. }
  1538.  
  1539. PropertiesPage.prototype.getTabLabel = PropertiesPage_getTabLabel;
  1540. PropertiesPage.prototype.canLoad = PropertiesPage_canLoad;
  1541. PropertiesPage.prototype.load = PropertiesPage_load;
  1542. PropertiesPage.prototype.update = PropertiesPage_update;
  1543. PropertiesPage.prototype.unload = PropertiesPage_unload;
  1544. PropertiesPage.prototype.lastUnload = PropertiesPage_lastUnload;
  1545.  
  1546. PropertiesPage.prototype.enable = PropertiesPage_enable;
  1547. PropertiesPage.prototype.disable = PropertiesPage_disable;
  1548.  
  1549. function PropertiesPage_getTabLabel()
  1550. {
  1551.   return this.tabLabel;
  1552. }
  1553.  
  1554. //Called to check if a page can be loaded
  1555. //
  1556. function PropertiesPage_canLoad()
  1557. {
  1558.   //alert("canLoad() called " + this.tabLabel);
  1559.   return true;
  1560. }
  1561.  
  1562. //Called when the layer for this page is displayed.
  1563. // Use this call to initialize controls.
  1564. //
  1565. function PropertiesPage_load()
  1566. {
  1567.   //alert("load() called " + this.tabLabel + " (loaded = " + this.loaded + ")");
  1568.   
  1569.   this.properties = new ListControl("properties");
  1570.   this.propName = dwscripts.findDOMObject("propName");
  1571.   this.propDisplayName = dwscripts.findDOMObject("propDisplayName");
  1572.   this.propDescription = dwscripts.findDOMObject("propDescription");
  1573.   //this.propAccess = new ListControl("propAccess");
  1574.   this.propType = new ListControl("propType");
  1575.   //this.propArray = dwscripts.findDOMObject("propArray");
  1576.   //this.propDefaultValue = dwscripts.findDOMObject("propDefaultValue");
  1577.   //this.propRequired = dwscripts.findDOMObject("propRequired");
  1578.   //this.propSearchable = dwscripts.findDOMObject("propSearchable");
  1579.   //this.propFullText = dwscripts.findDOMObject("propFullText");
  1580.   
  1581.   // populate access list
  1582.   //this.propAccess.setAll(LABEL_ACCESSES,LABEL_ACCESSES);
  1583.   //this.propAccess.pickValue(DEFAULT_ACCESS);
  1584.   
  1585.   // populate the type list
  1586.   this.propType.setAll(LABEL_TYPES,LABEL_TYPES);
  1587.   
  1588.   this.update('refresh');
  1589. }
  1590.  
  1591. //Called when one of the page controls calls the tabControl update function.
  1592. // Use this call to respond to user input.
  1593. //
  1594. function PropertiesPage_update(theItemName)
  1595. {
  1596.   //alert("update() called for " + theItemName + " on " + this.tabLabel);
  1597.   
  1598.   if (theItemName == "refresh")
  1599.   {
  1600.     // populate the properties array
  1601.     var nameArray = new Array();
  1602.     for (var i=0; i < COMPONENT_INFO.properties.length; i++)
  1603.     {
  1604.       nameArray.push(COMPONENT_INFO.properties[i].name); // function call?
  1605.     }
  1606.     this.properties.setAll(nameArray);
  1607.  
  1608.     if (this.selectedProperty != -1)
  1609.     {
  1610.       this.properties.setIndex(this.selectedProperty);
  1611.     }
  1612.  
  1613.     // now update the rest of the display
  1614.     this.update('properties');
  1615.   }
  1616.   else if (theItemName == "btn_propPlus")
  1617.   {
  1618.     var property = new PropertyInfo();
  1619.     property.name = getUniqueName(LABEL_Property, COMPONENT_INFO.properties);
  1620.     COMPONENT_INFO.properties.push(property);  // should we insert this after selection?
  1621.     
  1622.     this.properties.append(property.name);
  1623.     this.properties.setIndex(COMPONENT_INFO.properties.length);
  1624.     
  1625.     this.update("properties");
  1626.   }
  1627.   else if (theItemName == "btn_propMinus")
  1628.   {
  1629.     var index = this.properties.getIndex();
  1630.     
  1631.     this.properties.del();
  1632.     
  1633.     // delete this property
  1634.     COMPONENT_INFO.properties.splice(index,1);
  1635.     
  1636.     this.update("properties");
  1637.   }
  1638.   else
  1639.   {
  1640.     var index = this.properties.getIndex();
  1641.     var property = null;
  1642.     if (index >= 0)
  1643.     {
  1644.       property = COMPONENT_INFO.properties[index];
  1645.     }
  1646.     
  1647.     if (property)
  1648.     {  
  1649.       this.enable();
  1650.       
  1651.       if (theItemName == "properties")
  1652.       {
  1653.         // update the other fields to display the currently
  1654.         //  selected item
  1655.         this.propName.value = property.name;
  1656.         this.propDisplayName.value = property.displayName;
  1657.         //this.propAccess.pickValue(property.access);
  1658.         this.propType.pickValue(property.type);
  1659.         //this.propArray.checked = property.isArray;
  1660.         this.propDescription.value = property.description;
  1661.         //this.propDefaultValue.value = property.defaultValue;
  1662.         //this.propRequired.checked = property.required;
  1663.         //this.propSearchable.checked = property.searchable;
  1664.         //this.propFullText.checked = property.fullText;
  1665.       }
  1666.       else if (theItemName == "propName")
  1667.       {
  1668.         if( "" == this.propName.value  || containsInvalidChars(this.propName.value) ) {
  1669.           alert(dwscripts.sprintf(MSG_Error_BlankName,LABEL_Property));
  1670.           dwscripts.findDOMObject("propName").focus();
  1671.         }
  1672.         else if ( nameExists(this.propName.value, this.properties) )
  1673.         {
  1674.           alert(dwscripts.sprintf(MSG_Error_NameExists, this.propName.value, LABEL_Property));
  1675.           dwscripts.findDOMObject("propName").focus();
  1676.         }
  1677.         else
  1678.         {
  1679.           property.name = this.propName.value;
  1680.           this.properties.set(property.name);
  1681.         }
  1682.       }
  1683.       else if (theItemName == "propDisplayName")
  1684.       {
  1685.         property.displayName = this.propDisplayName.value;
  1686.       }
  1687.       else if (theItemName == "propAccess")
  1688.       {
  1689.         //property.access = this.propAccess.getValue();
  1690.       }
  1691.       else if (theItemName == "propType")
  1692.       {
  1693.         var newValue = this.propType.getValue();
  1694.         if (property.type != newValue)
  1695.         {
  1696.           property.type = newValue;
  1697.           // need to repick the value to work around a bug
  1698.           this.propType.pickValue(property.type);
  1699.         }
  1700.       }
  1701.       else if (theItemName == "propDescription")
  1702.       {
  1703.         property.description = this.propDescription.value;
  1704.       }
  1705.       else if (theItemName == "propDefaultValue")
  1706.       {
  1707.         //property.defaultValue = this.propDefaultValue.value;
  1708.       }
  1709.       else if (theItemName == "propRequired")
  1710.       {
  1711.         //property.required = this.propRequired.checked;
  1712.       }
  1713.     }
  1714.     else
  1715.     {
  1716.       // clear items
  1717.       this.propName.value = "";
  1718.       this.propDisplayName.value = "";
  1719.       //this.propAccess.pickValue("public");
  1720.       this.propType.pickValue("string");
  1721.       //this.propArray.checked = false;
  1722.       this.propDescription.value = "";
  1723.       //this.propDefaultValue.value = "";
  1724.       //this.propRequired.checked = false;
  1725.       //this.propSearchable.checked = false;
  1726.       //this.propFullText.checked = false;
  1727.       
  1728.       // disable form
  1729.       this.disable();
  1730.     }
  1731.   }
  1732. }
  1733.  
  1734. //Called when another page is about to be shown, or finish() is called on
  1735. // the tabControl.  Use this call to perform any finishing tasks.
  1736. //
  1737. function PropertiesPage_unload()
  1738. {
  1739.   //alert("unload() called " + this.tabLabel);
  1740.   
  1741.   this.selectedProperty = this.properties.getIndex();
  1742.   
  1743.   // hack to make sure that controls disappear correctly
  1744.   T.obj.visibility = "hidden";
  1745.   T.obj.visibility = "visible";
  1746.   
  1747.   return true;
  1748. }
  1749.  
  1750. //Called when finish() is called on the tabControl.
  1751. // Use this call to perform any last minute page updates.
  1752. //
  1753. function PropertiesPage_lastUnload()
  1754. {
  1755.   //alert("lastUnload() called " + this.tabLabel);
  1756.   return true;
  1757. }
  1758.  
  1759.  
  1760. function PropertiesPage_enable()
  1761. {
  1762.   if (!this.pageIsEnabled)
  1763.   {
  1764.     this.pageIsEnabled = true;
  1765.     this.propName.removeAttribute("disabled");
  1766.     this.propDisplayName.removeAttribute("disabled");
  1767.     //this.propAccess.enable();
  1768.     this.propType.enable();
  1769.     //this.propArray.removeAttribute("disabled");
  1770.     this.propDescription.removeAttribute("disabled");
  1771.     //this.propDefaultValue.removeAttribute("disabled");
  1772.     //this.propRequired.removeAttribute("disabled");
  1773.     //this.propSearchable.removeAttribute("disabled");
  1774.     //this.propFullText.removeAttribute("disabled");
  1775.   }
  1776. }
  1777.  
  1778. function PropertiesPage_disable()
  1779. {
  1780.   if (this.pageIsEnabled)
  1781.   {
  1782.     this.pageIsEnabled = false;
  1783.     this.propName.setAttribute("disabled","true");
  1784.     this.propDisplayName.setAttribute("disabled","true");
  1785.     //this.propAccess.disable();
  1786.     this.propType.disable();
  1787.     //this.propArray.setAttribute("disabled","true");
  1788.     this.propDescription.setAttribute("disabled","true");
  1789.     //this.propDefaultValue.setAttribute("disabled","true");
  1790.     //this.propRequired.setAttribute("disabled","true");
  1791.     //this.propSearchable.setAttribute("disabled","true");
  1792.     //this.propFullText.setAttribute("disabled","true");
  1793.   }
  1794. }
  1795.  
  1796.  
  1797.  
  1798. //--------------------------------------------------------------------
  1799. // CLASS:
  1800. //   MethodsPage
  1801. //
  1802. // DESCRIPTION:
  1803. //   This class handles the display and update of the methods page
  1804. //
  1805. // PUBLIC PROPERTIES:
  1806. //   NONE
  1807. //
  1808. // PUBLIC FUNCTIONS:
  1809. //   NONE
  1810. //
  1811. //--------------------------------------------------------------------
  1812.  
  1813. function MethodsPage(theTabLabel)
  1814. {
  1815.   this.tabLabel = theTabLabel;
  1816.   
  1817.   this.methods = "";
  1818.   this.methodName = "";
  1819.   this.methodDisplayName = "";
  1820.   this.methodDescription = "";
  1821.   this.methodAccess = "";
  1822.   this.methodRoles = "";
  1823.   //this.methodStatic1 = "";
  1824.   this.methodResultType = "";
  1825.   this.methodOutput = "";
  1826.   
  1827.   this.selectedMethod = -1;
  1828.   
  1829.   this.pageIsEnabled = true;
  1830. }
  1831.  
  1832. MethodsPage.prototype.getTabLabel = MethodsPage_getTabLabel;
  1833. MethodsPage.prototype.canLoad = MethodsPage_canLoad;
  1834. MethodsPage.prototype.load = MethodsPage_load;
  1835. MethodsPage.prototype.update = MethodsPage_update;
  1836. MethodsPage.prototype.unload = MethodsPage_unload;
  1837. MethodsPage.prototype.lastUnload = MethodsPage_lastUnload;
  1838.  
  1839. MethodsPage.prototype.enable = MethodsPage_enable;
  1840. MethodsPage.prototype.disable = MethodsPage_disable;
  1841.  
  1842. function MethodsPage_getTabLabel()
  1843. {
  1844.   return this.tabLabel;
  1845. }
  1846.  
  1847. //Called to check if a page can be loaded
  1848. //
  1849. function MethodsPage_canLoad()
  1850. {
  1851.   //alert("canLoad() called " + this.tabLabel);
  1852.   return true;
  1853. }
  1854.  
  1855. //Called when the layer for this page is displayed.
  1856. // Use this call to initialize controls.
  1857. //
  1858. function MethodsPage_load()
  1859. {
  1860.   //alert("load() called " + this.tabLabel + " (loaded = " + this.loaded + ")");
  1861.   
  1862.   this.methods = new ListControl("methods");
  1863.   
  1864.   this.methodName = dwscripts.findDOMObject("methodName");
  1865.   this.methodDisplayName = dwscripts.findDOMObject("methodDisplayName");
  1866.   this.methodDescription = dwscripts.findDOMObject("methodDescription");
  1867.   this.methodAccess = new ListControl("methodAccess");
  1868.   this.methodRoles = dwscripts.findDOMObject("methodRoles");
  1869.   //this.methodStatic1 = dwscripts.findDOMObject("methodStatic1");
  1870.   this.methodResultType = new ListControl("methodResultType");
  1871.   this.methodOutput = dwscripts.findDOMObject("methodOutput");
  1872.   
  1873.   // populate the access list
  1874.   this.methodAccess.setAll(LABEL_ACCESSES,LABEL_ACCESSES);
  1875.   this.methodAccess.pickValue(DEFAULT_ACCESS);
  1876.   
  1877.   // populate the result type list
  1878.   var newList = new Array("none");
  1879.   var completeList = newList.concat(LABEL_TYPES);
  1880.   this.methodResultType.setAll(completeList,completeList);
  1881.  
  1882.   this.update("refresh");
  1883. }
  1884.  
  1885. //Called when one of the page controls calls the tabControl update function.
  1886. // Use this call to respond to user input.
  1887. //
  1888. function MethodsPage_update(theItemName)
  1889. {
  1890.   //alert("update() called for " + theItemName + " on " + this.tabLabel);
  1891.  
  1892.   if (theItemName == "refresh")
  1893.   {
  1894.     // populate the methods array
  1895.     var nameArray = new Array();
  1896.     for (var i=0; i < COMPONENT_INFO.methods.length; i++)
  1897.     {
  1898.       nameArray.push(COMPONENT_INFO.methods[i].name); // function call?
  1899.     }
  1900.     this.methods.setAll(nameArray);
  1901.  
  1902.     if (this.selectedMethod != -1)
  1903.     {
  1904.       this.methods.setIndex(this.selectedMethod);
  1905.     }
  1906.  
  1907.     // now update the rest of the display
  1908.     this.update('methods');
  1909.   }
  1910.   else if (theItemName == "btn_methodPlus")
  1911.   {
  1912.     var method = new MethodInfo();
  1913.     method.name = getUniqueName(LABEL_Method, COMPONENT_INFO.methods);
  1914.     COMPONENT_INFO.methods.push(method);  // should we insert this after selection?
  1915.     
  1916.     this.methods.append(method.name);
  1917.     this.methods.setIndex(COMPONENT_INFO.methods.length);
  1918.     
  1919.     this.update("methods");
  1920.   }
  1921.   else if (theItemName == "btn_methodMinus")
  1922.   {
  1923.     var index = this.methods.getIndex();
  1924.     
  1925.     this.methods.del();
  1926.     
  1927.     // delete this property
  1928.     COMPONENT_INFO.methods.splice(index,1);
  1929.     
  1930.     this.update("methods");
  1931.   }
  1932.   else
  1933.   {
  1934.     var index = this.methods.getIndex();
  1935.     var method = null;
  1936.     if (index >= 0)
  1937.     {
  1938.       method = COMPONENT_INFO.methods[index];
  1939.     }
  1940.     
  1941.     if (method)
  1942.     {
  1943.       this.enable();
  1944.       
  1945.       if (theItemName == "methods")
  1946.       {
  1947.         // update the other fields to display the currently
  1948.         //  selected item
  1949.         this.methodName.value = method.name;
  1950.         this.methodDisplayName.value = method.displayName;
  1951.         this.methodDescription.value = method.description;
  1952.         this.methodAccess.pickValue(method.access);
  1953.         this.methodRoles.value = method.roles;
  1954.         //this.methodStatic1.checked = method.isStatic;
  1955.         this.methodResultType.pickValue(method.resultType);
  1956.         this.methodOutput.checked = method.output;
  1957.       }
  1958.       else if (theItemName == "methodName")
  1959.       {
  1960.         if( "" == this.methodName.value  || containsInvalidChars(this.methodName.value) ) {
  1961.           alert(dwscripts.sprintf(MSG_Error_BlankName,LABEL_Method));
  1962.           dwscripts.findDOMObject("methodName").focus();
  1963.         }
  1964.         else if ( nameExists(this.methodName.value, this.methods) )
  1965.         {
  1966.           alert(dwscripts.sprintf(MSG_Error_NameExists, this.methodName.value, LABEL_Method));
  1967.           dwscripts.findDOMObject("methodName").focus();
  1968.         }
  1969.         else
  1970.         {
  1971.           method.name = this.methodName.value;
  1972.           this.methods.set(method.name);
  1973.         }
  1974.       }
  1975.       else if (theItemName == "methodDisplayName")
  1976.       {
  1977.         method.displayName = this.methodDisplayName.value;
  1978.       }
  1979.       else if (theItemName == "methodDescription")
  1980.       {
  1981.         method.description = this.methodDescription.value;
  1982.       }
  1983.       else if (theItemName == "methodAccess")
  1984.       {
  1985.         method.access = this.methodAccess.getValue();
  1986.       }
  1987.       else if (theItemName == "methodRoles")
  1988.       {
  1989.         method.roles = this.methodRoles.value;
  1990.       }
  1991.       //else if (theItemName == "methodStatic1")
  1992.       //{
  1993.         //method.isStatic = this.methodStatic1.checked;
  1994.       //}
  1995.       else if (theItemName == "methodResultType")
  1996.       {
  1997.         var newValue = this.methodResultType.getValue();
  1998.         if (method.resultType != newValue)
  1999.         {
  2000.           method.resultType = newValue;
  2001.           // need to repick the value to work around a bug
  2002.           this.methodResultType.pickValue(method.resultType);
  2003.         }
  2004.       }
  2005.       else if (theItemName == "methodOutput")
  2006.       {
  2007.         method.output = this.methodOutput.checked;
  2008.       }
  2009.     }
  2010.     else
  2011.     {
  2012.       // clear items
  2013.       this.methodName.value = "";
  2014.       this.methodDisplayName.value = "";
  2015.       this.methodDescription.value = "";
  2016.       this.methodAccess.pickValue("public");
  2017.       this.methodRoles.value = "";
  2018.       //this.methodStatic1.checked = false;
  2019.       this.methodResultType.pickValue("");
  2020.       this.methodOutput.checked = false;
  2021.       
  2022.       // disable form
  2023.       this.disable();
  2024.     }
  2025.   }
  2026. }
  2027.  
  2028. //Called when another page is about to be shown, or finish() is called on
  2029. // the tabControl.  Use this call to perform any finishing tasks.
  2030. //
  2031. function MethodsPage_unload()
  2032. {
  2033.   //alert("unload() called " + this.tabLabel);
  2034.  
  2035.   this.selectedMethod = this.methods.getIndex();
  2036.   
  2037.   // hack to make sure that controls disappear correctly
  2038.   T.obj.visibility = "hidden";
  2039.   T.obj.visibility = "visible";
  2040.   
  2041.   return true;
  2042. }
  2043.  
  2044. //Called when finish() is called on the tabControl.
  2045. // Use this call to perform any last minute page updates.
  2046. //
  2047. function MethodsPage_lastUnload()
  2048. {
  2049.   //alert("lastUnload() called " + this.tabLabel);
  2050.   return true;
  2051. }
  2052.  
  2053.  
  2054. function MethodsPage_enable()
  2055. {
  2056.   if (!this.pageIsEnabled)
  2057.   {
  2058.     this.pageIsEnabled = true;
  2059.     this.methodName.removeAttribute("disabled");
  2060.     this.methodDisplayName.removeAttribute("disabled");
  2061.     this.methodDescription.removeAttribute("disabled");
  2062.     this.methodAccess.enable();
  2063.     this.methodRoles.removeAttribute("disabled");
  2064.     //this.methodStatic1.removeAttribute("disabled");
  2065.     this.methodResultType.enable();
  2066.     this.methodOutput.removeAttribute("disabled");
  2067.   }
  2068. }
  2069.  
  2070. function MethodsPage_disable()
  2071. {
  2072.   if (this.pageIsEnabled)
  2073.   {
  2074.     this.pageIsEnabled = false;
  2075.     this.methodName.setAttribute("disabled","true");
  2076.     this.methodDisplayName.setAttribute("disabled","true");
  2077.     this.methodDescription.setAttribute("disabled","true");
  2078.     this.methodAccess.disable();
  2079.     this.methodRoles.setAttribute("disabled","true");
  2080.     //this.methodStatic1.setAttribute("disabled","true");
  2081.     this.methodResultType.disable();
  2082.     this.methodOutput.setAttribute("disabled","true");
  2083.   }
  2084. }
  2085.  
  2086.  
  2087.  
  2088. //--------------------------------------------------------------------
  2089. // CLASS:
  2090. //   ParametersPage
  2091. //
  2092. // DESCRIPTION:
  2093. //   This class handles the display and update of the parameters page
  2094. //
  2095. // PUBLIC PROPERTIES:
  2096. //   NONE
  2097. //
  2098. // PUBLIC FUNCTIONS:
  2099. //   NONE
  2100. //
  2101. //--------------------------------------------------------------------
  2102.  
  2103. function ParametersPage(theTabLabel)
  2104. {
  2105.   this.tabLabel = theTabLabel;
  2106.   
  2107.   this.readOnlyMethods = "";
  2108.   
  2109.   this.parameters = "";
  2110.   this.parameterName = "";
  2111.   this.parameterDisplayName = "";
  2112.   this.parameterDescription = "";
  2113.   this.parameterType = "";
  2114.   //this.parameterArray = "";
  2115.   this.parameterRequired = "";
  2116.   this.parameterDefaultValue = "";
  2117.   
  2118.   
  2119.   this.selectedMethod = -1;
  2120.   this.selectedParameter = -1;
  2121.   
  2122.   this.paramsEnabled = true;
  2123.   this.pageIsEnabled = true;
  2124. }
  2125.  
  2126. ParametersPage.prototype.getTabLabel = ParametersPage_getTabLabel;
  2127. ParametersPage.prototype.canLoad = ParametersPage_canLoad;
  2128. ParametersPage.prototype.load = ParametersPage_load;
  2129. ParametersPage.prototype.update = ParametersPage_update;
  2130. ParametersPage.prototype.unload = ParametersPage_unload;
  2131. ParametersPage.prototype.lastUnload = ParametersPage_lastUnload;
  2132.  
  2133. ParametersPage.prototype.enable = ParametersPage_enable;
  2134. ParametersPage.prototype.disable = ParametersPage_disable;
  2135.  
  2136. function ParametersPage_getTabLabel()
  2137. {
  2138.   return this.tabLabel;
  2139. }
  2140.  
  2141. //Called to check if a page can be loaded
  2142. //
  2143. function ParametersPage_canLoad()
  2144. {
  2145.   //alert("canLoad() called " + this.tabLabel);
  2146.   return true;
  2147. }
  2148.  
  2149. //Called when the layer for this page is displayed.
  2150. // Use this call to initialize controls.
  2151. //
  2152. function ParametersPage_load()
  2153. {
  2154.   //alert("load() called " + this.tabLabel + " (loaded = " + this.loaded + ")");
  2155.   
  2156.   this.readOnlyMethods = new ListControl("readOnlyMethods");
  2157.   this.parameters = new ListControl("parameters");
  2158.   this.parameterName = dwscripts.findDOMObject("parameterName");
  2159.   this.parameterDisplayName = dwscripts.findDOMObject("parameterDisplayName");
  2160.   this.parameterDescription = dwscripts.findDOMObject("parameterDescription");
  2161.   this.parameterType = new ListControl("parameterType");
  2162.   //this.parameterArray = dwscripts.findDOMObject("parameterArray");
  2163.   this.parameterRequired = dwscripts.findDOMObject("parameterRequired");
  2164.   this.parameterDefaultValue = dwscripts.findDOMObject("parameterDefaultValue");
  2165.   
  2166.   // populate the parameter type array
  2167.   this.parameterType.setAll(LABEL_TYPES,LABEL_TYPES);
  2168.   
  2169.   this.update("refresh");
  2170. }
  2171.  
  2172. //Called when one of the page controls calls the tabControl update function.
  2173. // Use this call to respond to user input.
  2174. //
  2175. function ParametersPage_update(theItemName)
  2176. {
  2177.   //alert("update() called for " + theItemName + " on " + this.tabLabel);
  2178.   
  2179.   if (theItemName == "refresh")
  2180.   {
  2181.     // populate the methods array
  2182.     var nameArray = new Array();
  2183.     for (var i=0; i < COMPONENT_INFO.methods.length; i++)
  2184.     {
  2185.       nameArray.push(COMPONENT_INFO.methods[i].name); // function call?
  2186.     }
  2187.     this.readOnlyMethods.setAll(nameArray,nameArray);
  2188.  
  2189.     if (this.selectedMethod != -1)
  2190.     {
  2191.       this.readOnlyMethods.setIndex(this.selectedMethod);
  2192.     }
  2193.  
  2194.     // now update the rest of the display
  2195.     this.update('readOnlyMethods');    
  2196.   }
  2197.   else
  2198.   {
  2199.     var index = this.readOnlyMethods.getIndex();
  2200.     var method = null;
  2201.     if (index >= 0)
  2202.     {
  2203.       method = COMPONENT_INFO.methods[index];
  2204.     }
  2205.  
  2206.     if (method)
  2207.     {
  2208.       if (!this.paramsEnabled)
  2209.       {
  2210.         this.parameters.enable();
  2211.         this.paramsEnabled = true;
  2212.         var plusButton = dwscripts.findDOMObject("btn_parameterPlus");
  2213.         plusButton.src = "../Shared/UltraDev/Images/PlusButton.gif";
  2214.         var minusButton = dwscripts.findDOMObject("btn_parameterMinus");
  2215.         minusButton.src = "../Shared/UltraDev/Images/MinusButtonEnabled.gif";
  2216.       }
  2217.  
  2218.       if (theItemName == "readOnlyMethods")
  2219.       {
  2220.         // populate the parameters array
  2221.         var nameArray = new Array();
  2222.         for (var i=0; i < method.parameters.length; i++)
  2223.         {
  2224.           nameArray.push(method.parameters[i].name); // function call?
  2225.         }
  2226.         this.parameters.setAll(nameArray,nameArray);
  2227.  
  2228.         if (this.selectedParameter != -1)
  2229.         {
  2230.           this.parameters.setIndex(this.selectedParameter);
  2231.           this.selectedParameter = -1;  // only select this the first time the page is visited
  2232.         }
  2233.         this.update("parameters");
  2234.       }
  2235.       if (theItemName == "btn_parameterPlus")
  2236.       {
  2237.         var parameter = new ParameterInfo();
  2238.         parameter.name = getUniqueName(LABEL_Parameter, method.parameters);
  2239.         method.parameters.push(parameter);  // should we insert this after selection?
  2240.  
  2241.         this.parameters.append(parameter.name);
  2242.         this.parameters.setIndex(method.parameters.length);
  2243.  
  2244.         this.update("parameters");
  2245.       }
  2246.       else if (theItemName == "btn_parameterMinus")
  2247.       {
  2248.         var paramIndex = this.parameters.getIndex();
  2249.  
  2250.         this.parameters.del();
  2251.  
  2252.         // delete this property
  2253.         method.parameters.splice(paramIndex,1);
  2254.  
  2255.         this.update("parameters");
  2256.       }
  2257.       else
  2258.       {
  2259.         var paramIndex = this.parameters.getIndex();
  2260.         var parameter = null;
  2261.         if (paramIndex >= 0)
  2262.         {
  2263.           parameter = method.parameters[paramIndex];
  2264.         }
  2265.  
  2266.         if (parameter)
  2267.         {
  2268.           this.enable();
  2269.  
  2270.           if (theItemName == "parameters")
  2271.           {
  2272.             // update the other fields to display the currently
  2273.             //  selected item
  2274.             this.parameterName.value = parameter.name;
  2275.             this.parameterDisplayName.value = parameter.displayName;
  2276.             this.parameterDescription.value = parameter.description;
  2277.             this.parameterType.pickValue(parameter.type);
  2278.             this.parameterRequired.checked = parameter.required;
  2279.             this.parameterDefaultValue.value = parameter.defaultValue;
  2280.           }
  2281.           else if (theItemName == "parameterName")
  2282.           {
  2283.             if( "" == this.parameterName.value  || containsInvalidChars(this.parameterName.value) ) {
  2284.               alert(dwscripts.sprintf(MSG_Error_BlankName,LABEL_Parameter));
  2285.               dwscripts.findDOMObject("parameterName").focus();
  2286.             }
  2287.             else if ( nameExists(this.parameterName.value, this.parameters) )
  2288.             {
  2289.               alert(dwscripts.sprintf(MSG_Error_NameExists, this.parameterName.value, LABEL_Parameter));
  2290.               dwscripts.findDOMObject("parameterName").focus();
  2291.             }
  2292.             else
  2293.             {
  2294.               parameter.name = this.parameterName.value;
  2295.               this.parameters.set(parameter.name);
  2296.             }
  2297.           }
  2298.           else if (theItemName == "parameterDisplayName")
  2299.           {
  2300.             parameter.displayName = this.parameterDisplayName.value;
  2301.           }
  2302.           else if (theItemName == "parameterDescription")
  2303.           {
  2304.             parameter.description = this.parameterDescription.value;
  2305.           }
  2306.           else if (theItemName == "parameterType")
  2307.           {
  2308.             var newValue = this.parameterType.getValue();
  2309.             if (parameter.type != newValue)
  2310.             {
  2311.               parameter.type = newValue;
  2312.               // need to repick the value to work around a bug
  2313.               this.parameterType.pickValue(parameter.type);
  2314.             }
  2315.           }
  2316.           else if (theItemName == "parameterRequired")
  2317.           {
  2318.             parameter.required = this.parameterRequired.checked;
  2319.           }
  2320.           else if (theItemName == "parameterDefaultValue")
  2321.           {
  2322.             parameter.defaultValue = this.parameterDefaultValue.value;
  2323.           }
  2324.         }
  2325.         else
  2326.         {
  2327.           // disable form
  2328.           this.disable();
  2329.         }
  2330.       }
  2331.     }
  2332.     else
  2333.     {
  2334.       if (this.paramsEnabled)
  2335.       {
  2336.         this.parameters.setAll(new Array());
  2337.         this.parameters.disable();
  2338.         this.paramsEnabled = false;
  2339.         var plusButton = dwscripts.findDOMObject("btn_parameterPlus");
  2340.         plusButton.src = "../Shared/UltraDev/Images/PlusButtonDisabled.gif";
  2341.         var minusButton = dwscripts.findDOMObject("btn_parameterMinus");
  2342.         minusButton.src = "../Shared/UltraDev/Images/MinusButtonDisabled.gif";
  2343.       }
  2344.       this.disable();
  2345.     }
  2346.   }
  2347. }
  2348.  
  2349. //Called when another page is about to be shown, or finish() is called on
  2350. // the tabControl.  Use this call to perform any finishing tasks.
  2351. //
  2352. function ParametersPage_unload()
  2353. {
  2354.   //alert("unload() called " + this.tabLabel);
  2355.  
  2356.   // hack to make sure that controls disappear correctly
  2357.   T.obj.visibility = "hidden";
  2358.   T.obj.visibility = "visible";
  2359.   
  2360.   return true;
  2361. }
  2362.  
  2363. //Called when finish() is called on the tabControl.
  2364. // Use this call to perform any last minute page updates.
  2365. //
  2366. function ParametersPage_lastUnload()
  2367. {
  2368.   //alert("lastUnload() called " + this.tabLabel);
  2369.   return true;
  2370. }
  2371.  
  2372.  
  2373. function ParametersPage_enable()
  2374. {
  2375.   if (!this.pageIsEnabled)
  2376.   {
  2377.     this.pageIsEnabled = true;
  2378.     this.parameterName.removeAttribute("disabled");
  2379.     this.parameterDisplayName.removeAttribute("disabled");
  2380.     this.parameterDescription.removeAttribute("disabled");
  2381.     this.parameterType.enable();
  2382.     this.parameterRequired.removeAttribute("disabled");
  2383.     this.parameterDefaultValue.removeAttribute("disabled");
  2384.   }
  2385. }
  2386.  
  2387. function ParametersPage_disable()
  2388. {
  2389.   if (this.pageIsEnabled)
  2390.   {
  2391.     this.pageIsEnabled = false;
  2392.  
  2393.     // clear items
  2394.     this.parameterName.value = "";
  2395.     this.parameterDisplayName.value = "";
  2396.     this.parameterDescription.value = "";
  2397.     this.parameterType.pickValue("string");
  2398.     this.parameterRequired.checked = false;
  2399.     this.parameterDefaultValue.value = "";
  2400.  
  2401.     // now disable
  2402.     this.parameterName.setAttribute("disabled","true");
  2403.     this.parameterDisplayName.setAttribute("disabled","true");
  2404.     this.parameterDescription.setAttribute("disabled","true");
  2405.     this.parameterType.disable();
  2406.     this.parameterRequired.setAttribute("disabled","true");
  2407.     this.parameterDefaultValue.setAttribute("disabled","true");
  2408.   }
  2409. }
  2410.  
  2411. // =================================================================================================
  2412. //--------------------------------------------------------------------
  2413. // FUNCTION:
  2414. //   getParentCfcs
  2415. //
  2416. // DESCRIPTION:
  2417. //   Makes an http request to the CFCExplorer to return and array of
  2418. //     CFC names
  2419. //
  2420. // ARGUMENTS:
  2421. //   refreshCache - determines whether to get a fresh list of CFCs or not
  2422. //
  2423. // RETURNS:
  2424. //   array containing the name of available CFCs
  2425. //--------------------------------------------------------------------
  2426. function getParentCfcs( refreshCache ) {
  2427.   if (refreshCache == null ) {
  2428.     refreshCache = "no";
  2429.   }
  2430.   var root = new Array();
  2431.   var cfcNames =  new Array();
  2432.   // first item will be "" so that it doesn't look like a parent is automatically selected
  2433.   cfcNames[0] = "";
  2434.   var cfcNamesLen = cfcNames.length;
  2435.   var wddxParentCfcs = "";
  2436.  
  2437.   var introspectionURL = getIntrospectionUrl();
  2438.   if (introspectionURL != "")
  2439.   {
  2440.  
  2441.     MM.setBusyCursor(); 
  2442.     var pwdBase64 = MMToBase64(MMDB.getRDSUserName() + ":" + MMDB.getRDSPassword());
  2443.     var strHeader = "Authorization-MX: Basic " + pwdBase64 + "\r\n";
  2444.     var httpReply = MMHttp.postText(introspectionURL + "?method=getcfcs&refreshcache=" + refreshCache, "", "", strHeader); 
  2445.  
  2446.     // only process WDDX if reply successful, else just return new Array()
  2447.     if (httpReply.statusCode == 200) {
  2448.       wddxParentCfcs = httpReply.data;
  2449.       //alert("raw WDDX packet\n\n" + wddxParentCfcs);
  2450.       var des = new WddxDeserializer();
  2451.       root = des.deserialize(wddxParentCfcs);
  2452.         // this happens to be null sometimes, ignore that it's null and just bring up the dialog
  2453.         if( root != null ) {
  2454.         for( var i=0; i<root.length; i++ ) {
  2455.           cfcNames[i+cfcNamesLen] = root[i].NAME;
  2456.         }
  2457.       }  
  2458.       // sorting and empty array seems to make it null and was throwing errors in  ListControlClass's setAll
  2459.       if( cfcNames.length >  0 ) {
  2460.         cfcNames = cfcNames.sort();
  2461.       }
  2462.     }
  2463.     MM.clearBusyCursor();       
  2464.   } else {
  2465.     //alert('no url prefix???');
  2466.   }
  2467.   return cfcNames;
  2468. }
  2469.  
  2470. //--------------------------------------------------------------------
  2471. // FUNCTION:
  2472. //   repopulateCompParent
  2473. //
  2474. // DESCRIPTION:
  2475. //   - calls methods to retrieve a fresh the list of available components
  2476. //
  2477. // ARGUMENTS:
  2478. //   NONE
  2479. //
  2480. // RETURNS:
  2481. //   NONE
  2482. //--------------------------------------------------------------------
  2483. function repopulateCompParent() {
  2484.     LABEL_PARENT_CFCS = getParentCfcs("yes");
  2485.     T.getPageObject("componentSection").compParent.setAll(LABEL_PARENT_CFCS,LABEL_PARENT_CFCS);
  2486. }
  2487.  
  2488. //--------------------------------------------------------------------
  2489. // FUNCTION:
  2490. //   getCfcRoots
  2491. //
  2492. // DESCRIPTION:
  2493. //   Makes an http request to the CFCExplorer to return and array of
  2494. //     CFC names
  2495. //
  2496. // ARGUMENTS:
  2497. //   refreshCache - determines whether to get a fresh list of CFCs or not
  2498. //
  2499. // RETURNS:
  2500. //   array containing the name of available CFCs
  2501. //--------------------------------------------------------------------
  2502. function getCfcRoots( refreshCache ) {
  2503.   if (refreshCache == null ) {
  2504.     refreshCache = "no";
  2505.   }
  2506.   var root = new Array();
  2507.   var cfcRoots =  new Array();
  2508.   // first item will be "" so that it doesn't look like a parent is automatically selected
  2509.   cfcRoots[0] = "";
  2510.   var cfcRootsLen = cfcRoots.length;
  2511.   var wddxCfcRoots = "";
  2512.  
  2513.   var introspectionURL = getIntrospectionUrl();
  2514.   if (introspectionURL != "")
  2515.   {
  2516.     MM.setBusyCursor(); 
  2517.     var pwdBase64 = MMToBase64(MMDB.getRDSUserName() + ":" + MMDB.getRDSPassword());
  2518.     var strHeader = "Authorization-MX: Basic " + pwdBase64 + "\r\n";
  2519.     var httpReply = MMHttp.postText(introspectionURL + "?method=getcomponentroots&refreshcache=" + refreshCache, "", "", strHeader); 
  2520.  
  2521.     // only process WDDX if reply successful, else just return new Array()
  2522.     if (httpReply.statusCode == 200) {
  2523.       wddxCfcRoots = httpReply.data;
  2524.       //alert("raw WDDX packet\n\n" + wddxCfcRoots);
  2525.       var des = new WddxDeserializer();
  2526.       root = des.deserialize(wddxCfcRoots);
  2527.       // this happens to be null sometimes, ignore that it's null and just bring up the dialog
  2528.         if( root != null ) {
  2529.         for( var i=0; i<root.length; i++ ) {
  2530.           cfcRoots[i+cfcRootsLen] = root[i].PHYSICALPATH;
  2531.         }
  2532.       }    
  2533.       // sorting and empty array seems to make it null and was throwing errors in  ListControlClass's setAll
  2534.       if( cfcRoots.length >  0 ) {
  2535.         cfcRoots = cfcRoots.sort();
  2536.       }
  2537.     }
  2538.     MM.clearBusyCursor();       
  2539.   } else {
  2540.     //alert('no url prefix???');
  2541.   }
  2542.   return cfcRoots;
  2543. }
  2544.     
  2545. function nameExists(name, listToSearch) {
  2546.   if( name != null ) {
  2547.     for ( var i=0; i<listToSearch.getLen(); i++ ) {
  2548.       // need to check that it's not being compared against the current index that it's 
  2549.       // trying to update! should the user not change the name
  2550.       if( name == listToSearch.get(i) && i != listToSearch.getIndex()) {
  2551.         return true;
  2552.       }
  2553.     }
  2554.   }
  2555.   return false;
  2556. }
  2557.  
  2558.